function render() {
    $.ajax({
      url: '/admin/comments',
      success: function (res) {
          console.log(res);
        if (res.status == 0) {
        //   console.log(res.message);
          let str = ''
          res.data.forEach(value => {
            str += ` <tr>
      <td>${value.id}</td>
      <td>{${value.uname}</td>
      <td>${value.content}</td>
      <td>${value.cdate}}</td>
      <td>
        <button data-id="${value.id}" type="button" class="layui-btn layui-btn-xs layui-btn-danger delete">
          删除
        </button>
      </td>
    </tr>`

          });
          $('tbody').html(str)
        }
      }
    })
  }
  render()
  $('tbody').on('click', '.delete', function () {
    $(this).parents('tr').remove()
    let id = $(this).data('id')
    $.ajax({
      url: `/admin/comments/` + id,
      type: 'DELETE',
      success: function (res) {
        if (res.status == 0) {
          console.log(res.message);
          
          }
          render()
        }
      
    })
   
  })